package com.hmall.search.web;

import com.hmall.common.dto.PageDTO;
import com.hmall.search.pojo.ItemDoc;
import com.hmall.search.pojo.Search;
import com.hmall.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    SearchService searchService;

    /**
     * 首页数据条
     * @param search
     * @return
     */
    @PostMapping("/filters")
    public Map<String,List<String>> search(@RequestBody Search search){
        return searchService.search(search);
    }


    /**
     * 数据查询
     */
    @PostMapping("/list")
    public PageDTO<ItemDoc> list(@RequestBody Search search){
        return searchService.list(search);
    }
}
